package com.kaili.finance;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;

import com.baomidou.mybatisplus.plugins.PaginationInterceptor;
import com.kaili.common.response.ResponseBodyWrapFactoryBean;
import com.kaili.common.util.PropertiesUtil;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * 财务子站
 * @Copyright: Copyright (c) 2017
 * @Company: 杭州凯立通信有限公司
 * @author zhengs
 * @version 1.0.0 2017年7月23日 下午1:51:40
 */
@MapperScan("com.kaili.finance.mapper*")
@ComponentScan(basePackages = "com.kaili.finance,com.kaili.common.aop,com.kaili.common.exception")
@EnableDiscoveryClient
@SpringBootApplication
//开启断路器功能
@EnableCircuitBreaker
@EnableFeignClients
@EnableTransactionManagement(proxyTargetClass = true)
@EnableRedisHttpSession(maxInactiveIntervalInSeconds = 18000)
@EnableSwagger2
public class FinanceServer {
	public static void main(String[] args) {
		new SpringApplicationBuilder(FinanceServer.class).web(true).run(args);
	}
	
	 /**
     * mybatis-plus 分页插件
     */
    @Bean
    public PaginationInterceptor paginationInterceptor() {
        PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
        paginationInterceptor.setLocalPage(true);
        paginationInterceptor.setDialectType("mysql"); 
        
        return paginationInterceptor;
    }
    
	/**
	 * 返回值包装
	 */
	@Bean
    public ResponseBodyWrapFactoryBean getResponseBodyWrap() {
        return new ResponseBodyWrapFactoryBean();
    }
}
